<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>gen</title>
</head>
<body>
	<div id="tree">
	<form>
		<input type="" name="">
	</form>
	<p>paragraph</p>
	<span>span</span>
	</div>
<script type="text/javascript">
	function idom(el,callback){
		callback(el);
		el=el.firstElementChild;
		while(el){
			idom(el, callback);
			el=el.nextElementSibling;
		}

	}
	const st=document.getElementById('tree');
	idom(st,el=>console.log(el));
	//遍历所有节点
	
	function* fordom(el){
		yield el;
		el=el.firstElementChild;
		while(el){
			yield* fordom(el);
			el=el.nextElementSibling;
		}
	}
	for(let el of fordom(st)){
		console.info(el);
	}
	//dom变成迭代器




















































































</script>
</body>
</html>